/*
 * $Id: StepTimeNType.java,v 1.4 2009/07/24 18:28:18 oliver Exp $
 *
 * Copyright (C) 2006 General Electric Company. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 *
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */

package com.ge.healthcare.autosc.common.pojo;

import java.util.Calendar;
import java.util.GregorianCalendar;

import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.pojo.HstStepTime;

public class StepTimeNType extends HstStepTime {
	/**
	 * Eclipse generated
	 */
	private static final long serialVersionUID = 9157753458499303200L;
	private String stepType;
	private String serverName;
	private Calendar gcStart = GregorianCalendar.getInstance();
	private Calendar gcEnd = GregorianCalendar.getInstance();

	public StepTimeNType(HstStepTime stepTime, String stepType, String serverName) {
		this.setStepTimeId(stepTime.getStepTimeId());
		this.setObjectId(stepTime.getObjectId());
		this.setObjectType(stepTime.getObjectType());
		this.setStepTypeId(stepTime.getStepTypeId());
		
		this.setStartTime(stepTime.getStartTime());
		gcStart.setTime(this.getStartTime());
		this.setEndTime(stepTime.getEndTime());
		gcEnd.setTime(this.getEndTime());
		
		this.setCodeId(stepTime.getCodeId());
		this.setStepType(stepType);
		this.setServerName(serverName);
	}
	public String getStepType() {
		return stepType;
	}
	public void setStepType(String stepType) {
		this.stepType = stepType;
	}
	public String getServerName() {
		return serverName;
	}
	public void setServerName(String servName) {
		this.serverName = servName;
	}
	public boolean isComplete(){
		if( ASCUtil.isNullOrEmptyObject(this.getEndTime())){
			return false;
		}
		return true;
	}
	public Long getDuration() {
		if( ASCUtil.isNullOrEmptyObject(this.getStartTime()) ){
			throw new RuntimeException( "StartTime is null or Empty unable to calc: Duration");
		} else if( ASCUtil.isNullOrEmptyObject(this.getEndTime())){
			throw new RuntimeException( "EndTime is null or Empty unable to calc: Duration");
		} else {
			Long duration =  gcEnd.getTimeInMillis() - gcStart.getTimeInMillis();
			return duration;
		}
	}

}
